#encoding: UTF-8

class OrderItem < ActiveRecord::Base
  attr_accessible :producto_id, :order_id, :price, :amount

  belongs_to :order
  belongs_to :producto

  def validate
    errors.add(:amount, "Tiene que ser superior o igual a 1") unless amount.nil? || amount > 0
    errors.add(:price, "Debe ser un numero positivo") unless price.nil? || price > 0.0
  end
end
